import json

from flask import Blueprint
from flask import request
from flask import Response

from app.comm.db import db
from app.comm.db import jsonformater
from app.comm.pub import RestEntity
from app.comm.pub import class2dict

dictservice = Blueprint('dict', __name__,)

@dictservice.route("/rest/system/dict/list",methods=['POST','GET'])
def postList():  
    #dict1 = json.loads(a)
    tables=db.session.execute("select dict_id dictId,dict_name dictName,dict_type dictType,status,create_time createTime,remark from sys_dict_type").fetchall()
    datas= [dict(r) for r in tables] 
    result=RestEntity(0,0,datas,"登陆成功！")
    return json.dumps(class2dict(result), default=jsonformater)
 
    #return json.dumps(dict1)         